import 'package:boss/textStyle/text_style.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class PackagePanel extends StatelessWidget {
  final List<Widget> children;
  final String title;
  final String subtitle;
  final TextStyle titleStyle;
  final EdgeInsets padding;
  final EdgeInsets contentPadding;
  final EdgeInsets headerPadding;
  final List<Widget> actions;
  final bool isRequired;

  const PackagePanel({
    Key key,
    this.padding,
    this.children,
    this.title,
    this.subtitle,
    this.titleStyle,
    this.contentPadding,
    this.actions,
    this.headerPadding,
    this.isRequired = false,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: padding ?? EdgeInsets.symmetric(horizontal: 30.w),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Container(
            alignment: Alignment.centerLeft,
            padding: headerPadding ?? EdgeInsets.symmetric(vertical: 30.w),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                RichText(
                  text: TextSpan(text: title, style: titleStyle ?? TextStyleConstant().normal_1_32, children: [
                    if (isRequired) TextSpan(text: '*', style: TextStyleConstant().origin_28),
                    if (subtitle != null)
                      TextSpan(
                        text: subtitle,
                        style: TextStyleConstant().normal_3_24,
                      )
                  ]),
                ),
                Row(
                  children: actions ?? [],
                ),
              ],
            ),
          ),
          Container(
            padding: contentPadding ?? EdgeInsets.symmetric(horizontal: 10.w),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: children,
            ),
          ),
        ],
      ),
    );
  }
}
